﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace ClassLibrary1
{
    public class Class1
    {
        public string sss(object ObjectID)
        {
            string[] sql = new string[4];
            StringBuilder str = new StringBuilder();
            str.Append(@" update A_ObjectInfo set ObjectRegNum=@ObjectReg ");
            str.AppendFormat(@" where ObjectID='{0}'", ObjectID);

            SqlParameter[] spr = new SqlParameter[]{
                                                    new SqlParameter("@ObjectReg",SqlDbType.VarChar,50)
                                                    };
            spr[0].Value = ObjectInfoModel.A_ObjectRegNum;

            sql[0] = str.ToString();
            str.Clear();

            str.Append(@" update A_RegisterModel set Writer=@Writer,WriteDate=@WriteDate,ContractNo=@ContractNo,ServiceFee=@ServiceFee ");
            str.AppendFormat(@" where ObjectID='{0}'", ObjectID);

            SqlParameter[] spr1 = new SqlParameter[]{
                                                    new SqlParameter("@Writer",SqlDbType.VarChar,50),        
                                                    };
            spr1[0].Value = RegisterModel.A_Writer;
            sql[1] = str.ToString();
            str.Clear();
        }

        public void sssss(object ObjectID)
        {

            StringBuilder str = new StringBuilder();
            str.AppendFormat(@" update A_ObjectInfo set ObjectRegNum=@ObjectReg where ObjectID='{0}' ", ObjectID);
            str.AppendFormat(@" update A_RegisterModel set Writer=@Writer,WriteDate=@WriteDate,ContractNo=@ContractNo,ServiceFee=@ServiceFee  where ObjectID='{0}'", ObjectID);


            SqlParameter[] spr = {
                                     new SqlParameter("@ObjectReg",SqlDbType.VarChar,50),
                                     new SqlParameter("@Writer",SqlDbType.VarChar,50),
                                    // new SqlParameter("@WriteDate",SqlDbType.VarChar,50)
                                    //new SqlParameter("@ContractNo",SqlDbType.VarChar,50)
                                   //new SqlParameter("@ServiceFee",SqlDbType.VarChar,50)
                                 };
            spr[0].Value = ObjectInfoModel.A_ObjectRegNum;
            spr[1].Value = RegisterModel.A_Writer;

            SqlCommand cmd = new SqlCommand(str.ToString(), connection, this);
            cmd.Parameters.Add(spr);

            SqlCommand cmd = new SqlCommand();
            cmd.Connection = _con;//命令对象  
            SqlTransaction myTransaction;//声明一个SQL事物类型  
            myTransaction = con.BeginTransaction();//基于一个连接初始化事物 

            cmd.Transaction = myTransaction;//指定SQL命令语句　的事物  
            cmd.CommandText = str.ToString();//给定命令语句  
            cmd.Parameters.AddRange(spr);//添加SQL参数
            //sql[0] = str.ToString();

            //str.Clear();

            //str.Append(@" update A_RegisterModel set Writer=@Writer,WriteDate=@WriteDate,ContractNo=@ContractNo,ServiceFee=@ServiceFee ");
            //str.AppendFormat(@" where ObjectID='{0}'", ObjectID);

            //SqlParameter[] spr1 = new SqlParameter[]{
            //                                        new SqlParameter("@Writer",SqlDbType.VarChar,50),        
            //                                        };
            //spr1[0].Value = RegisterModel.A_Writer;
            //sql[1] = str.ToString();
            //str.Clear();
        }
    }
}
